﻿//  Copyright (c) 2010 Ray Liang (http://www.dotnetage.com)
//  Dual licensed under the MIT and GPL licenses:
//  http://www.opensource.org/licenses/mit-license.php
//  http://www.gnu.org/licenses/gpl.html

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;
using System.Xml.Serialization;

namespace DNA.OpenAPI.Atom
{
    /// <summary>
    /// The <c>AtomLink</c>class defines a reference from an entry or feed to a Web resource. 
    /// This specification assigns no meaning to the content (if any) of this element. 
    /// </summary>
    [XmlRoot("link", Namespace = "http://www.w3.org/2005/Atom"), 
    Serializable]
    public struct AtomLink
    {
        /// <summary>
        /// The "href" attribute contains the link's IRI. atom:link elements MUST have an href attribute, 
        /// whose value MUST be a IRI reference [RFC3987].
        /// </summary>
        [XmlAttribute("href")]
        public string NavigateUrl;

        /// <summary>
        /// atom:link elements MAY have a "rel" attribute that indicates the link relation type. If the "rel" 
        /// attribute is not present, the link element MUST be interpreted as if the link relation type is "alternate".
        /// </summary>
        /// <remarks>
        /// The value of "rel" MUST be a string that is non-empty and matches either the "isegment-nz-nc" or the "IRI" production in [RFC3987]. 
        /// Note that use of a relative reference other than a simple name is not allowed. If a name is given, implementations MUST consider the link
        /// relation type equivalent to the same name registered within the IANA Registry of Link Relations (Section 7), and thus to the IRI that would be 
        /// obtained by appending the value of the rel attribute to the string "http://www.iana.org/assignments/relation/". The value of "rel" describes the 
        /// meaning of the link, but does not impose any behavioral requirements on Atom Processors.
        /// </remarks>
        [XmlAttribute("rel")]
        public string Rel;

        /// <summary>
        /// On the link element, the "type" attribute's value is an advisory media type: it is a hint about the type of the representation 
        /// that is expected to be returned when the value of the href attribute is dereferenced. Note that the type attribute does not 
        /// override the actual media type returned with the representation. Link elements MAY have a type attribute, whose value MUST
        /// conform to the syntax of a MIME media type [MIMEREG].
        /// </summary>
        [XmlAttribute("type")]
        public string Type;

        /// <summary>
        /// The "hreflang" attribute's content describes the language of the resource pointed to by the href attribute. 
        /// When used together with the rel="alternate", it implies a translated version of the entry.
        /// Link elements MAY have an hreflang attribute, whose value MUST be a language tag [RFC3066].
        /// </summary>
        [XmlAttribute("hreflang")]
        public string NavigateUrlLanguage;

        /// <summary>
        /// The "title" attribute conveys human-readable information about the link.
        /// The content of the "title" attribute is Language-Sensitive. Entities such as "&amp;" and "&lt;" 
        /// represent their corresponding characters ("&amp;" and "&lt;" , respectively), not markup. Link elements MAY have a title attribute.
        /// </summary>
        [XmlAttribute("title")]
        public string Text;

        /// <summary>
        /// The "length" attribute indicates an advisory length of the linked content in octets; 
        /// it is a hint about the content length of the representation returned when the IRI in the href attribute is mapped to a URI and dereferenced.
        /// Note that the length attribute does not override the actual content length of the representation as reported by the underlying protocol. 
        /// Link elements MAY have a length attribute.
        /// </summary>
        [XmlAttribute("length")]
        public string Length;
    }
}